package com.jiepu.daily.corejava.advanceed.part7io.day0810;

import org.junit.Test;

import java.io.*;

/**
 * @Description:
 * @author: xinjie
 * @date: 2020/8/10  8:18
 */
public class IODemo13 {

	@Test
	public void write() throws IOException {

		Student student = new Student(1002, "Xin");
		String path = "src/com/jiepu/daily/advanceed/part7_io/io_test/demo10.txt";
		FileOutputStream fos = new FileOutputStream(path);
		ObjectOutputStream oos = new ObjectOutputStream(fos);
		oos.writeObject(student);
		oos.close();
		System.out.println("over...");

	}
	@Test
	public void read() throws IOException, ClassNotFoundException {
		String path = "src/com/jiepu/daily/advanceed/part7_io/io_test/demo10.txt";
		FileInputStream fis = new FileInputStream(path);
		ObjectInputStream ois = new ObjectInputStream(fis);
		Object obj= ois.readObject();
		System.out.println(obj);
	}


}


